package com.demo.globalexception;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常设置
 * 
 * @author Fairylan
 *
 */
@ControllerAdvice
public class GloBalDefaultExceptionHandler {

	@ExceptionHandler(Exception.class)
	@ResponseBody
	public Map<String, Object> defaultExceptionHandler(HttpServletRequest request, Exception e) {
		// ModelAndView mv=new ModelAndView();
		// mv.setViewName("");
		Map<String, Object> map = new HashMap<>();
		map.put("result", "RC300");
		map.put("errMsg", e.getMessage());
		// return "服务器繁忙,请稍候重试。";
		return map;

	}
}
